﻿create PROCEDURE Sync.SP_UsersCommittees_SelectChanges
@LastRowVersion rowversion,
@FilterdColumn UNIQUEIDENTIFIER
AS 
BEGIN 
	SELECT 
        t.[CommitteeID],t.[UserID],
		
		t.IsDeleted,
		t.LastUpdatedDate
	FROM [dbo].[UsersCommittees] g RIGHT JOIN Sync.UsersCommittees_Tracking t  
    ON t.CommitteeID = g.CommitteeID AND t.UserID = g.UserID 
	WHERE (@LastRowVersion IS NULL OR t.Version > @LastRowVersion)
        AND (@FilterdColumn IS NULL OR g.CommitteeID = @FilterdColumn)
    END














